package Dao;

import java.sql.Connection;
import ui.weatherInfo;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public  class weatherDao {
    weatherInfo weatherInfo = new weatherInfo();
    private static final String DELETE_SQL = "DELETE FROM weather_info;";
    //定义一个清空数据库的方法
    public static void deleteWeather(){


        //调用数据库的操作
        try (
                Connection connection = DatabaseConnection.getConnection();
                PreparedStatement preparedStatement = connection.prepareStatement(DELETE_SQL)) {

            int rowinserted = preparedStatement.executeUpdate();
            if (rowinserted > 0) {
                System.out.println("删除weather表数据成功");}
            else {
                System.out.println("删除失败");
            }
        } catch (SQLException e) {

            e.printStackTrace();
        }
    }

}
